package baseball.controller;

import baseball.domain.User;
import baseball.domain.User;
import baseball.mapper.UserMapper;
import baseball.support.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;

@RequestMapping("member/user")
@Controller

public class MemberUserController extends BaseController {
    @Autowired
    private UserMapper userMapper;

    /**
     * 全部列表
     *
     * @param model
     * @return
     */
    @RequestMapping("list")
    private String list(Model model) {
        List<User> list = userMapper.selectAll();
        model.addAttribute("list", list);
        return "member/user/list";
    }


    /**
     * 删除用户
     *
     * @param id
     * @return
     */
    @RequestMapping("del/{id}")
    public String del(@PathVariable Integer id) {
        userMapper.deleteByPrimaryKey(id);
        return refresh();
    }
}
